<template>
	<view class="content"></view>
</template>

<script>
import { getDownloadUrlByCode } from '@/api/aw.js';
import { mapState } from 'vuex';
export default {
	components: {},
	computed: {
		...mapState(['sysInfo'])
	},
	data() {
		return {
			url: ''
		};
	},
	onLoad(options) {
		// code  acceptLanguage
		const { code, acceptLanguage } = options;
		//console.log(options);
		if (code) {
			getDownloadUrlByCode({ code, acceptLanguage }).then(res => {
				this.downloadVideo(res.data);
			});
		}
	},
	onBackPress(event) {
		// let pages = getCurrentPages();
		// let page = pages[pages.length - 1];
		// let currentPages = page.$getAppWebview();
		// currentPages.close();
		// return false;s
	},
	methods: {
		downloadVideo(url) {
			// uni.showLoading({ title: 'Downloading...' });

			// 动态创建 <a> 标签触发下载
			const link = document.createElement('a');
			link.href = url;

			// 设置下载文件名（可选，需服务器支持文件名解析）
			// const filename = url.split('/').pop() || 'video.mp4';
			//link.download = filename;

			// 必须由用户点击触发（浏览器安全策略）
			document.body.appendChild(link);
			link.click();
			document.body.removeChild(link);

			// uni.hideLoading();
		},
		close() {
			//let ua = window.navigator.userAgent.toLowerCase();
			window.location.href = 'about:blank';
			window.close();
		}
	}
};
</script>

<style>
.content {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.logo {
	height: 200rpx;
	width: 200rpx;
	margin-top: 200rpx;
	margin-left: auto;
	margin-right: auto;
	margin-bottom: 50rpx;
}

.text-area {
	display: flex;
	justify-content: center;
}

.title {
	font-size: 36rpx;
	color: #8f8f94;
}
</style>
